<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./1-vue3.js"></script>
  <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.js"></script>
</head>
<body>
  <div id="app">
    {{swipeData.data}}
    <div v-for="item in swipeData.data" :key="item.id">
      <img width="150px" :src="item.url" alt="">
    </div>
  </div>
  <script>
    console.log(Vue);
    let ref=Vue.ref;
    let onMounted=Vue.onMounted;
    let app = Vue.createApp({
      data(){
        return {
          msg:'hello vue3'
        } 
      },
      // created(){
      //   alert('mounted')
      // },
      setup(){
        console.log(this);
        alert('setUp')
        // 初始化 查询轮播图
        // 1.数据
        let swipeData=ref([]);
        // console.log(JSON.stringify(swipeData.value),'11111');
        // 封装轮播图的函数
        let loadSwipeData= async function(){
          swipeData.value = await axios.get('http://121.199.0.35:8888/index/carousel/findAll');
        };
        onMounted(loadSwipeData);
        // 将查询到的初始化数据 注册到mounted中 等到生命周期执行到mounted执行
        return {
          swipeData
        }
      }
    }).mount('#app');
  </script>
</body>
</html>